export function getSelect(userId) {
  return new Promise((resolve, reject) => {
    this.axios.post(this.lib.config.host.masterData + "/system/purOrgMgt/purOrg/getPurOrgByUserId/" + userId,{}).then((response) => {
      let result = response.data.map(item=>{
        let purOrg = {
          value : item['id'],
          label : item['purOrgName']
        };
        return purOrg;
      });
      resolve(result);
    }).catch((error) => {
      reject(error);
    });
  });
}


export function getGroupSelect(purOrgId) {
  return new Promise((resolve, reject) => {
    this.axios.post(this.lib.config.host.masterData + "/mdata/purOrgMgt/purGroup/getByPurOrgId/" + purOrgId,{}).then((response) => {
      let result = response.data.map(item=>{
        let purGroup = {
          value : item['id'],
          label : item['purGroupName']
        };
        return purGroup;
      });
      resolve(result);
    }).catch((error) => {
      reject(error);
    });
  });
}

export default {
  getSelect,
  getGroupSelect
}